using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Procurements
{
    public class PurchaseOrderAutoMapperProfile : Profile
    {
        public PurchaseOrderAutoMapperProfile()
        {
            CreateMap<PurchaseOrder, PurchaseOrderDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseOrder, PurchaseOrderDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseOrder, PurchaseOrderCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseOrder, PurchaseOrderUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<PurchaseOrderUpdateDto, PurchaseOrder>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.Supplier, opt => opt.Ignore())
                .ForMember(dest => dest.Operator, opt => opt.Ignore())
                .MapChildren<PurchaseOrderUpdateDto, PurchaseOrder, PurchaseOrderLineCreateOrUpdateDto, PurchaseOrderLine>();

            CreateMap<PurchaseOrderLine, PurchaseOrderLineDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseOrderLine, PurchaseOrderLineCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 